package javabase.schoolwork.day6_5;

/**
 * @author fance
 * @date 2018/6/5 21:09
 */
class Person implements Cloneable {
    private String name = null;

    public Person(String name) {
        this.name = name;
    }

    @Override
    protected Object clone() throws CloneNotSupportedException {
        return super.clone();
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Override
    public String toString() {
        return "Person{" +
                "name='" + name + '\'' +
                '}';
    }
}
public class CloneDemo {
    public static void main(String[] args) throws CloneNotSupportedException {
        Person person = new Person("张三");
        Person person1 = (Person) person.clone();
        person1.setName("李四");
        System.out.println(person);
        System.out.println(person1);
        System.out.println(person == person1);
    }
}
